package com.hig.risk.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.hig.risk.domain.RiskSelfInspectionBasis;
import com.hig.risk.service.IRiskSelfInspectionBasisService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 重大隐患判定依据Controller
 * 
 * @author scp
 * @date 2024-11-29
 */
@RestController
@RequestMapping("/risk/basis")
public class RiskSelfInspectionBasisController extends BaseController
{
    @Autowired
    private IRiskSelfInspectionBasisService riskSelfInspectionBasisService;

    /**
     * 查询重大隐患判定依据列表
     */
    @PreAuthorize("@ss.hasPermi('risk:basis:list')")
    @GetMapping("/list")
    public TableDataInfo list(RiskSelfInspectionBasis riskSelfInspectionBasis)
    {
        startPage();
        List<RiskSelfInspectionBasis> list = riskSelfInspectionBasisService.selectRiskSelfInspectionBasisList(riskSelfInspectionBasis);
        return getDataTable(list);
    }

    /**
     * 导出重大隐患判定依据列表
     */
    @PreAuthorize("@ss.hasPermi('risk:basis:export')")
    @Log(title = "重大隐患判定依据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RiskSelfInspectionBasis riskSelfInspectionBasis)
    {
        List<RiskSelfInspectionBasis> list = riskSelfInspectionBasisService.selectRiskSelfInspectionBasisList(riskSelfInspectionBasis);
        ExcelUtil<RiskSelfInspectionBasis> util = new ExcelUtil<RiskSelfInspectionBasis>(RiskSelfInspectionBasis.class);
        return util.exportExcel(list, "重大隐患判定依据数据");
    }

    /**
     * 获取重大隐患判定依据详细信息
     */
    @PreAuthorize("@ss.hasPermi('risk:basis:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(riskSelfInspectionBasisService.selectRiskSelfInspectionBasisById(id));
    }

    /**
     * 新增重大隐患判定依据
     */
    @PreAuthorize("@ss.hasPermi('risk:basis:add')")
    @Log(title = "重大隐患判定依据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RiskSelfInspectionBasis riskSelfInspectionBasis)
    {
        return toAjax(riskSelfInspectionBasisService.insertRiskSelfInspectionBasis(riskSelfInspectionBasis));
    }

    /**
     * 修改重大隐患判定依据
     */
    @PreAuthorize("@ss.hasPermi('risk:basis:edit')")
    @Log(title = "重大隐患判定依据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RiskSelfInspectionBasis riskSelfInspectionBasis)
    {
        return toAjax(riskSelfInspectionBasisService.updateRiskSelfInspectionBasis(riskSelfInspectionBasis));
    }

    /**
     * 删除重大隐患判定依据
     */
    @PreAuthorize("@ss.hasPermi('risk:basis:remove')")
    @Log(title = "重大隐患判定依据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(riskSelfInspectionBasisService.deleteRiskSelfInspectionBasisByIds(ids));
    }

    @GetMapping("/allList")
    public AjaxResult allList(RiskSelfInspectionBasis riskSelfInspectionBasis)
    {
        List<RiskSelfInspectionBasis> list = riskSelfInspectionBasisService.selectAllBasis(riskSelfInspectionBasis);
        return AjaxResult.success(list);
    }

    @GetMapping("/allBasis")
    public AjaxResult allBasis(RiskSelfInspectionBasis riskSelfInspectionBasis)
    {
        List<RiskSelfInspectionBasis> list = riskSelfInspectionBasisService.selectAllBasisList(riskSelfInspectionBasis);
        return AjaxResult.success(list);
    }
}
